home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Language / Compiler / set.h < prev    next >
C/C++ Source or Header  |  1990-08-16  |  1KB  |  63 lines

  1. /*
  2.  * @(#)set.h    1.2  6/29/87
  3.  */
  4. #ifndef set_h
  5. #define set_h
  6.  
  7. /*
  8.  * Sets contain sets of integers.  There are
  9.  * create, insert, lookup, and destroy operations.
  10.  */
  11.  
  12. typedef struct STE {
  13.     int key;            /* the key for this entry */
  14. } STE, *STEPtr;
  15.  
  16. typedef struct SetRecord {
  17.     STEPtr table;
  18.     int maxIndex, maxCount, count;
  19. } SetRecord, *Set;
  20.  
  21. #define NIL ((unsigned)0x80000000)
  22.  
  23. Set Set_Create();
  24.  
  25. Set Set_CreateSized(/* count */);
  26. /* int count */
  27.  
  28. void Set_Insert(/* set, key, value */);
  29. /* Set set; int key, value; */
  30. #define SET_INSERT(s,e) {if (s == NULL) s = Set_Create(); Set_Insert(s, (int)e); }
  31.  
  32. int Set_Lookup(/* set, key */);
  33. /* Set set; int key; */
  34.  
  35. void Set_Delete(/* set, key */);
  36. /* Set set; int key; */
  37.  
  38. void Set_Destroy(/* set */);
  39. /* Set set; */
  40.  
  41. void Set_Print(/* set */);
  42. /* Set set; */
  43.  
  44. void Set_Merge(/* from, to */);
  45. /* Set from, to; */
  46.  
  47. #define Set_Size(s) ((s) == NULL ? 0 : (s)->count)
  48. #define Set_GetFirst(s, f) { \
  49.     int z__z = 0; \
  50.     Set_FindNext((s), &z__z, (int *)&f); \
  51.   }
  52.  
  53. #define Set_For(key, m) \
  54.   { \
  55.     int z__z = 0; \
  56.     while (Set_FindNext((m), &z__z, (int *)&key)) {
  57. #define Set_Next \
  58.     } \
  59.   }
  60.  
  61. #define Set_Count(m) ((m)->count)
  62. #endif
  63.